public class FormatString {
    public String formatString (String str, char[] arg) {
        // write code here
        String[] ss = str.split("%s");
        int index = 0;
        StringBuilder ret = new StringBuilder();
        for (String s : ss) {
            ret.append(s);
            ret.append(arg[index++]);
        }
        while (index < arg.length) {
            ret.append(arg[index++]);
        }
        return ret.toString();
    }
}
